package inet

type ConnectionCallback interface {
	OnConnectionStart(conn PublicConn)
	OnConnectionEnd(conn PublicConn)
}

type BaseConnectionCallback struct {
	calls []ConnectionCallback
}

func (b *BaseConnectionCallback) AddCallback(callback ConnectionCallback) {
	b.calls = append(b.calls, callback)
}

func (b *BaseConnectionCallback) OnConnectionStart(conn PublicConn) {
	for _, call := range b.calls {
		call.OnConnectionStart(conn)
	}
}

func (b *BaseConnectionCallback) OnConnectionEnd(conn PublicConn) {
	for _, call := range b.calls {
		call.OnConnectionEnd(conn)
	}
}
